package com.ww.springboot.boot.javabase.queue;

import com.google.common.collect.Queues;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2024-08-13 09:37
 */
public class BlockingQueueDemo2 {

    public static void main(String[] args) throws InterruptedException {

        System.out.println(args.length);

        List<BlockingQueue> list = new ArrayList<>();

        for (int i = 0; i < 100; i++) {
            BlockingQueue blockingQueue = new ArrayBlockingQueue<>(2048, true);
            for (int j = 0; j < 3000; j++) {
                blockingQueue.offer("1234567890123456712345678901111");
            }
            list.add(blockingQueue);
        }

        System.out.println(list);




//        while (true){
//            Long t1 = System.currentTimeMillis();
//            List<String> pkgCodes = new ArrayList<>();
//            Queues.drain(blockingQueue, pkgCodes, 300, 100, TimeUnit.MILLISECONDS);
//            Long t2 = System.currentTimeMillis();
//            System.out.println(pkgCodes.size() + " 耗时：" + (t2 - t1));
//        }
    }
}
